home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / term / win.trm < prev    next >
Text File  |  1993-05-24  |  6KB  |  245 lines

  1. /* GNUPLOT - term/win.trm */
  2. /*
  3.  * Copyright (C) 1992   Maurice Castro, Russell Lang
  4.  *
  5.  * Permission to use, copy, and distribute this software and its
  6.  * documentation for any purpose with or without fee is hereby granted, 
  7.  * provided that the above copyright notice appear in all copies and 
  8.  * that both that copyright notice and this permission notice appear 
  9.  * in supporting documentation.
  10.  *
  11.  * Permission to modify the software is granted, but not the right to
  12.  * distribute the modified code.  Modifications are to be distributed 
  13.  * as patches to released version.
  14.  *  
  15.  * This software is provided "as is" without express or implied warranty.
  16.  * 
  17.  *
  18.  * AUTHORS
  19.  * 
  20.  *   Gnuplot for Windows:
  21.  *       Maurice Castro, Russell Lang
  22.  * 
  23.  * There is a mailing list for gnuplot users. Note, however, that the
  24.  * newsgroup 
  25.  *    comp.graphics.gnuplot 
  26.  * is identical to the mailing list (they
  27.  * both carry the same set of messages). We prefer that you read the
  28.  * messages through that newsgroup, to subscribing to the mailing list.
  29.  * (If you can read that newsgroup, and are already on the mailing list,
  30.  * please send a message info-gnuplot-request@dartmouth.edu, asking to be
  31.  * removed from the mailing list.)
  32.  *
  33.  * The address for mailing to list members is
  34.  *       info-gnuplot@dartmouth.edu
  35.  * and for mailing administrative requests is 
  36.  *       info-gnuplot-request@dartmouth.edu
  37.  * The mailing list for bug reports is 
  38.  *       bug-gnuplot@dartmouth.edu
  39.  * The list of those interested in beta-test versions is
  40.  *       info-gnuplot-beta@dartmouth.edu
  41.  */
  42.  
  43.  
  44. /* This file implements the terminal and printer display for gnuplot  */
  45. /* under Microsoft Windows. The code currently compiles only with the */
  46. /* Borland C++ 3.1 compiler.                                          */
  47. /*                                                                    */
  48. /* The modifications to allow Gnuplot to run under Windows were made  */
  49. /* by Maurice Castro (maurice@bruce.cs.monash.edu.au)                 */
  50. /* and Russell Lang (rjl@monu1.cc.monash.edu.au)         19 Nov 1992  */
  51. /*                                                                    */
  52.  
  53. /* Edit this file with tabstop=4 (vi :se ts=4)                        */
  54.  
  55. #include <windows.h>
  56. #include "../win/wgnuplib.h"
  57.  
  58. extern GW graphwin;
  59.  
  60. char win_prntmp[256];    /* printer temporary file */
  61.  
  62. /* Initialization values - Guess Now Scale later */
  63. #define WIN_XMAX (2400)
  64. #define WIN_YMAX (1800)
  65. #define WIN_HCHAR (WIN_XMAX/75) 
  66. #define WIN_VCHAR (WIN_YMAX/25)
  67. #define WIN_HTIC (WIN_XMAX/160)
  68. #define WIN_VTIC WIN_HTIC
  69.  
  70. /* Interface routines - create list of actions for Windows */
  71.  
  72. WIN_options()
  73. {
  74.     extern struct value *const_express();
  75.     extern double real();
  76.  
  77.     if (!END_OF_COMMAND) {
  78.         if (almost_equals(c_token,"d$efault")) {
  79.             graphwin.color=TRUE;
  80.             strcpy(graphwin.fontname,WINFONT);
  81.             graphwin.fontsize = WINFONTSIZE;
  82.             c_token++;
  83.         }
  84.     }
  85.  
  86.     if (!END_OF_COMMAND) {
  87.         if (almost_equals(c_token,"m$onochrome")) {
  88.             graphwin.color=FALSE;
  89.             c_token++;
  90.         }
  91.         else if (almost_equals(c_token,"c$olor")) {
  92.             graphwin.color=TRUE;
  93.             c_token++;
  94.         }
  95.     }
  96.  
  97.     if (!END_OF_COMMAND && isstring(c_token)) {
  98.         quote_str(graphwin.fontname,c_token);
  99.         c_token++;
  100.     }
  101.  
  102.     if (!END_OF_COMMAND) {
  103.         /* We have font size specified */
  104.         struct value a;
  105.         graphwin.fontsize = (int)real(const_express(&a));
  106.     }
  107.  
  108.     if (graphwin.fontname[0] == '\0')
  109.       sprintf(term_options,"%s", graphwin.color ? "color" :  "monochrome");
  110.     else
  111.       sprintf(term_options,"%s \"%s\" %d", graphwin.color ? "color" :  "monochrome" ,
  112.         graphwin.fontname, graphwin.fontsize);
  113.     if (IsWindow(graphwin.hWndGraph) && IsIconic(graphwin.hWndGraph)) {
  114.         ShowWindow(graphwin.hWndGraph, SW_SHOWNORMAL);
  115.     }
  116.     GraphRedraw(&graphwin);
  117. }
  118.  
  119. /* We don't actually do scaling, but we need to fix up the text size
  120.  * if the user has resized the window */
  121. int WIN_scale()
  122. {
  123.     term_tbl[term].h_char = graphwin.hchar;
  124.     term_tbl[term].v_char = graphwin.vchar;
  125.     sprintf(term_options,"%s \"%s\" %d", graphwin.color ? "color" :  "monochrome" ,
  126.         graphwin.fontname, graphwin.fontsize);
  127.     return FALSE ;    /* can't be done */
  128. }
  129.  
  130. WIN_init()
  131. {
  132.     if (!graphwin.hWndGraph) {
  133.         graphwin.xmax = WIN_XMAX;
  134.         graphwin.ymax = WIN_YMAX;
  135.         graphwin.htic = WIN_HTIC;
  136.         graphwin.vtic = WIN_VTIC;
  137.         GraphInit(&graphwin);
  138.         SetClassWord(graphwin.hWndGraph, GCW_HICON, LoadIcon(graphwin.hInstance, "grpicon"));
  139.         graphwin.resized = FALSE;
  140.     }
  141. }
  142.  
  143.  
  144. WIN_reset()
  145. {
  146. }
  147.  
  148. WIN_text()
  149. {
  150.     GraphEnd(&graphwin);
  151. }
  152.  
  153. WIN_graphics()
  154. {
  155.     GraphStart(&graphwin);
  156. }
  157.  
  158. WIN_move(x, y)
  159. unsigned int x, y;
  160. {
  161.     GraphOp(&graphwin, W_move, x, y, NULL);
  162. }
  163.  
  164. WIN_vector(x,y)
  165. unsigned int x, y;
  166. {
  167.     GraphOp(&graphwin, W_vect, x, y, NULL);
  168. }
  169.  
  170. WIN_linetype(lt)
  171. int lt;
  172. {
  173.     GraphOp(&graphwin, W_line_type, lt, 0, NULL);
  174. }
  175.  
  176. WIN_put_text(x,y,str)
  177. int x, y;
  178. char *str;
  179. {
  180.     GraphOp(&graphwin, W_put_text, x, y, str);
  181. }
  182.  
  183. int WIN_justify_text(mode)
  184. enum JUSTIFY mode;
  185. {
  186.     GraphOp(&graphwin, W_justify, mode, 0, NULL);
  187.     return(TRUE);
  188. }
  189.  
  190. int WIN_text_angle(ang)
  191. int ang;
  192. {
  193.     if (graphwin.rotate)
  194.         GraphOp(&graphwin, W_text_angle, ang, 0, NULL);
  195.     return graphwin.rotate;
  196. }
  197.  
  198. WIN_point(x,y,number)
  199. int x,y;
  200. int number;
  201. {
  202.     /* draw point shapes later to save memory */
  203.     graphwin.htic = term_tbl[term].h_tic / 2;     /* size of point symbols */
  204.     graphwin.vtic = term_tbl[term].v_tic / 2;
  205.     if (number>=0)
  206.         number %= POINT_TYPES;
  207.     number += 1;
  208.     GraphOp(&graphwin, W_dot + number, x, y, NULL);
  209. }
  210.  
  211.  
  212. /* Windows PRN emulation */
  213. FILE *
  214. open_printer()
  215. {
  216. char *temp;
  217.     if ((temp = getenv("TEMP")) == (char *)NULL)
  218.         *win_prntmp='\0';
  219.     else  {
  220.         strncpy(win_prntmp,temp,MAX_ID_LEN-1);
  221.         /* stop X's in path being converted by mktemp */
  222.         for (temp=win_prntmp; *temp; temp++)
  223.             *temp = tolower(*temp);
  224.         if ( strlen(win_prntmp) && (win_prntmp[strlen(win_prntmp)-1]!='\\') )
  225.             strcat(win_prntmp,"\\");
  226.     }
  227.     strncat(win_prntmp, "_gptmp",MAX_ID_LEN-strlen(win_prntmp));
  228.     strncat(win_prntmp, "XXXXXX",MAX_ID_LEN-strlen(win_prntmp));
  229.     mktemp(win_prntmp);
  230.     return fopen(win_prntmp, "w");
  231. }
  232.  
  233. void
  234. close_printer()
  235. {
  236.     fclose(outfile);
  237.     DumpPrinter(graphwin.hWndGraph, graphwin.Title, win_prntmp);
  238. }
  239.  
  240. void
  241. screen_dump(void)
  242. {
  243.     GraphPrint(&graphwin);
  244. }
  245.